package com.px.project.module.ht.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.px.project.module.ht.entity.Camera;
import com.px.project.module.ht.entity.VideoRecorder;
import com.px.project.module.ht.service.CameraService;
import com.px.project.module.ht.service.VideoRecorderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 调令》视频回放
 *
 * @author 品讯科技
 * @since 2023-10-10
 */
@RestController
@RequestMapping("/videoPlayback")
public class VideoPlaybackController {

    @Autowired
    private VideoRecorderService videoRecorderService;

    @Autowired
    private CameraService cameraService;

    /**
     * 录像机下拉列表
     *
     * @return {@link List }<{@link VideoRecorder }>
     * @author 品讯科技
     * @date 2024-08
     */
    @GetMapping("/videoRecorderlist")
    public List<VideoRecorder> videolist() {
        return videoRecorderService.list();
    }

    /**
     * 摄像头下拉列表
     *
     * @return {@link List }<{@link VideoRecorder }>
     * @author 品讯科技
     * @date 2024-08
     */
    @GetMapping("/cameralist/{videoRecorderId}")
    public List<Camera> videolist(@PathVariable Long videoRecorderId) {
        VideoRecorder videoRecorder = videoRecorderService.getById(videoRecorderId);
        return cameraService.list(new LambdaQueryWrapper<Camera>()
                .eq(Camera::getDeviceNo, videoRecorder.getDeviceNo()));
    }

}
